<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动态操作样式</title>
    <style type="text/css">
        .highlight{
            background-color: black;
            color: white;
            width: 250px;
            height: 250px;
            line-height: 250px;
            text-align: center;
            font-size: 30px;
        }
    </style>
</head>
<body>
    <p id='box'>TEST03</p>
    <script type="text/javascript">
        /* // nodeObj.style */
        var para = document.getElementById('box');
        /*
         1.直接操作样式属性
        console.log(para.style);
        para.style.color = 'white';
        para.style.backgroundColor = 'black';
        para.style.width = '150px';
        para.style.height = '150px';
        para.style.textAlign = 'center';
        para.style.lineHeight = '150px';
        para.style.fontSize = '30px';
        */

        // 2. 通过控制属性的类名来控制样式
        para.setAttribute('class','highlight');
    </script>
</body>
</html>